#include <stdio.h>

void SelectionSort(int *a, int len)
{
	int i, j, min, k;
	for(k = 0; k < len; k ++)
	{
		printf("%d ", a[k]);
	}
	printf("\n");
	printf("\n");
	for(i = 0; i < len - 1; i++)
	{
		min = i;
		for(j = i+1;j < len; j++)
		{
			if(a[j] < a[min])
			{
				min = j;
			}
		}
		if(a[i] != a[min])
		{
			a[i] = a[i] ^ a[min];
			a[min] = a[i] ^ a[min];
			a[i] = a[i] ^ a[min];
		}

		for(k = 0; k < len; k ++)
		{
			printf("%d ", a[k]);
		}
		printf("\n");
	}		
	return;
}

int main()
{
   /*  Write C code in this online editor and run it. */
    int a[7] = {8, 5, 6, 7, 1, 3, 4};
	int len = sizeof(a) / sizeof(int);
	SelectionSort(&a[0], len);
   
   return 0;
}